<?php
/** 
 * Drug_model
 * This class is used for the Ajax searching for a drug name 
 * 
 * @author Ray Nowell
 *	
 */
class Drug_model extends Model {

	function Drug_model()
	{
		parent::Model();
	}
	
	function get_drug_list($passed_page)
	{
		$select_fields =	"	 drug_id
								,item_desc
								,generic_desc
								,size_code
								,size_qty
								,strength_code
								,strength_qty
								,nddf_awp
								,nddf_ndc_number
								,nddf_package_size_qty
								,pack_size
								,wholesale_cost
								,wholesale_each_cost
								,doses_per_day";
		//Get the query results for the clinical facilities
		$this->db->select($select_fields, false);
		$this->db->order_by('`generic_desc`, `item_desc`');
		$query = $this->db->get('drug_list',10,$passed_page);
		
		//$query = $this->db->get('drug_list',20,20);
		 
		return $query->result_array();
	}
	
	function get_drug_id_record($drug_id)
	{
		 $query = $this->db->limit(1)->get_where('drug_list', array('drug_id' => $drug_id));

		 return $query->row();
	}
	
	function seek_drugs( $drug_match )
	{
		//$this->output->enable_profiler(TRUE);
		$this->db->select('drug_id');
		$this->db->select('CONCAT(`generic_desc`,\' - \', `item_desc`) AS full_drug_description', FALSE);
		$this->db->select('wholesale_each_cost'); //Unit Cost
		$this->db->select('doses_per_day'); 
		$this->db->like('item_desc',$drug_match);
		$this->db->or_like('generic_desc', $drug_match);
		$this->db->order_by('`generic_desc`, `item_desc`'); 
		$query=$this->db->get('drug_list', 8); //REN:  Eight keeps it on the form
		
		return $query->result();
	}	
	
	
	
}

/* End of file drug_model.php */
/* Location: ./system/application/models/drug_model.php */